home *** CD-ROM | disk | FTP | other *** search
/ Pascal Super Library / Pascal Super Library (CW International)(1997).bin / GAMES / P_ROBO31 / RUNNER.PR < prev    next >
Text File  |  1989-10-23  |  3KB  |  73 lines

  1. (**************************************************************************)
  2. (*                             W A R N I N G                              *)
  3. (*                                                                        *)
  4. (*  This Robot has NOT been designed to take advantage of the advanced    *)
  5. (*  features of P-ROBOTS, such as, Shields, Fuel, Teams or Obstructions.  *)
  6. (**************************************************************************)
  7.  
  8.   PROCEDURE RUNNER;
  9.  
  10. {
  11.                             Based on C-Robot RUNNER
  12.  
  13.                                   by T. Harnish
  14.  
  15.                    "There I was with my back to the wall..."
  16.  
  17.                    Except for pre-positioning, everything is
  18.                    inline  code and has as few variables  as
  19.                    possible  to make this sucker as fast  as
  20.                    it can be. Some tweaking  of scan   width
  21.                    might   be   interesting.   The   obvious
  22.                    disadvantage of this guy is  that he  can
  23.                    never reach a 'bot running on  the  right
  24.                    edge, and could result in a draw if  they
  25.                    never get within 700 units of each other.
  26.  
  27.  
  28. }
  29.  
  30.     PROCEDURE GOTO(dest_x, dest_y : Integer); { go to lower left corner }
  31.     BEGIN
  32.       WHILE (distance(loc_x, loc_y, dest_x, dest_y) > 100) DO
  33.         IF (speed = 0) THEN drive(Angle_To(dest_x, dest_y), 100);
  34.  
  35.       drive(0, 0); {i.e., stop}
  36.       WHILE (speed > 0) DO {nothing-- i.e., slow down} ;
  37.     END; { End GoTO }
  38.  
  39.  
  40.   BEGIN { Main routine }
  41.  
  42.  
  43.     GOTO(0, 0); { Go to lower left corner }
  44.  
  45.     REPEAT { Main loop }
  46.       WHILE (loc_y < 850) DO BEGIN { Check for top }
  47.         drive(90, 100); { Go up }
  48.         IF (scan(0, 10) > 0) THEN { Look across }
  49.           cannon(0, scan(0, 10)); { Shoot if you see anything }
  50.         IF (scan(90, 10) > 0) THEN { Look where you are going }
  51.           cannon(90, scan(90, 10)); { Shoot if you see anything }
  52.         IF (scan(270, 10) > 0) THEN { Check your rear }
  53.           cannon(270, scan(270, 10)); { Shoot if you see anything }
  54.       END;
  55.       drive(90, 0); { Near top, slow down }
  56.       WHILE (speed > 50) DO ; { Wait for slow to 50 }
  57.  
  58.       WHILE (loc_y > 150) DO BEGIN { Check for bottom }
  59.         drive(270, 100); { Go down, if you'll pardon the expression }
  60.         IF (scan(0, 10) > 0) THEN { Look across }
  61.           cannon(0, scan(0, 10)); { Shoot, as before }
  62.         IF (scan(270, 10) > 0) THEN { Look where you're going }
  63.           cannon(270, scan(270, 10)); { Shoot, as before }
  64.         IF (scan(90, 10) > 0) THEN { Check your rear }
  65.           cannon(90, scan(90, 10)); { Shoot if you see anything }
  66.       END;
  67.       drive(270, 0); { Slow down }
  68.       WHILE (speed > 50) DO ; { Wait for 50 }
  69.  
  70.     UNTIL Dead OR Winner;
  71.  
  72.   END; { End RUNNER Main }
  73.